#!/bin/sh
cd ${0%/*} || exit 1    # run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

# -- Create paraview file
paraFoam -builtin -touch

# -- Pre-process the stl
runApplication surfaceFeatures

# -- Create the mesh for the fluid
runApplication blockMesh

# -- Decompose the mesh
runApplication decomposePar -copyZero

# -- Cut out the stl
runParallel snappyHexMesh -overwrite

# -- Add internal patch
runParallel addEmptyPatch internalPatch internal -overwrite

# -- Set the initial conditions for the fluid
for i in 1 2
do
    runParallel -s $i rotateFields ../2D -sourceTime 40.0e-3 -additionalFields '(rho lambda.tnt)'

    runParallel -s $i setRefinedFields -updateAll
done

runParallel rotateFields ../2D -sourceTime 40.0e-3 -additionalFields '(rho lambda.tnt)' -uniform

#- Run the calc
runParallel $(getApplication)

# ----------------------------------------------------------------- end-of-file
